package com.goodlearning.gloriamobile.activity;

import com.goodlearning.gloriamobile.commons.SyncTaskManager;
import com.goodlearning.gloriamobile.commons.SyncTaskManager.HandlerTask;
import com.goodlearning.gloriamobile.commons.SyncTaskManager.ThreadTask;
import com.goodlearning.gloriamobile.commons.Utils;
import com.goodlearning.gloriamobile.customdialog.LoginDialog;
import com.goodlearning.gloriamobile.customdialog.LoginDialog.ILoginCallback;
import com.goodlearning.gloriamobile.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * Intro 첫진입
 * 
 * @author rapty54
 * 
 */
public class Intro extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.intro);
		Utils.setContentBackgroundDrawable(this, R.drawable.ic_launcher,findViewById(R.id.intro_LinearLayout));

		LoginDialog.logout(this);

		new SyncTaskManager(this, new ThreadTask() {

			@Override
			public Object startLogicTask() {

				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {

					e.printStackTrace();
				}
				return null;
			}
		}, new HandlerTask() {

			@Override
			public void startHandlerTask(Object rtnObj) {

				if (isFinishing()) {
					return;
				}
				//기존 Dialog 로 진행되는 사항 Activity 로 변경
				
//				/**
//				 * 이부분서 Login callBack 받으면 바로 로그인 창치우고 Main Activity 로 바로 진입한다.
//				 * 
//				 */
//				LoginDialog.show(Intro.this, new ILoginCallback() {
//
//					@Override
//					public boolean handleMessage(String userId, String userPw) {
//
//						Utils.log("User Id:" + "[" + userId + "]" + "User Pw:"+ "[" + userPw + "]");
//
//						if (!userId.equals("") || !userPw.equals("")) {
//							Intent intent = new Intent(Intro.this, Plan.class);
//							intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//							startActivity(intent);
//							finish();
//						}
//
//						return false;
//					}
//				});
				
				Intent intent = new Intent(Intro.this, LoginActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
				finish();
			}
		}).start(false);
	}
	
	@Override
	public void onBackPressed() {
		
//		super.onBackPressed();
		finish();
	}
}
